package bl.history;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;

import po.销售明细po;
import blservice.history.SaleLogBLService;
import vo.销售明细vo;
import dbservice.history.SaleLogDBService;

public class SaleLogBL extends UnicastRemoteObject implements SaleLogBLService{
	private static final long serialVersionUID = 3781585971312119817L;
	private SaleLogDBService saleLogDB;

	public SaleLogBL(SaleLogDBService db) throws RemoteException{
		saleLogDB=db;
	}
	
	public List<销售明细vo> get() throws RemoteException{
		return P2V(saleLogDB.get());
	}
	
	public List<销售明细vo> get(销售明细vo from,销售明细vo to) throws RemoteException{
		return P2V(saleLogDB.get(V2P(from),V2P(to)));
	}
	
	private List<销售明细vo> P2V(List<销售明细po> po){
		List<销售明细vo> vo=new ArrayList<销售明细vo>();
		for(销售明细po o:po){
			vo.add(P2V(o));
		}
		return vo;
	}
	
	private 销售明细po V2P(销售明细vo vo){
		销售明细po po=new 销售明细po();
		po.set单价(vo.get单价());
		po.set商品名(vo.get商品名());
		po.set型号(vo.get型号());
		po.set总额(vo.get总额());
		po.set数量(vo.get数量());
		po.set时间(vo.get时间());
		po.set业务员(vo.get业务员());
		po.set仓库(vo.get仓库());
		po.set客户(vo.get客户());
		return po;
	}
	
	private 销售明细vo P2V(销售明细po po){
		销售明细vo vo=new 销售明细vo();
		vo.set单价(po.get单价());
		vo.set商品名(po.get商品名());
		vo.set型号(po.get型号());
		vo.set总额(po.get总额());
		vo.set数量(po.get数量());
		vo.set时间(po.get时间());
		vo.set业务员(po.get业务员());
		vo.set仓库(po.get仓库());
		vo.set客户(po.get客户());
		return vo;
	}
}
